// 测试用户数据
export const testUsers = [
  // 管理员账号
  {
    id: 'admin_001',
    email: 'admin@guigangwenlv.com',
    phone: '13800138001',
    password: 'Admin123456', // 实际项目中应该使用加密密码
    userType: 'admin',
    username: '系统管理员',
    avatar: '/avatars/admin.png',
    permissions: [
      'system:manage',
      'user:manage',
      'merchant:manage',
      'content:manage',
      'order:manage',
      'statistics:view'
    ],
    status: 'active',
    createTime: '2024-01-01 00:00:00'
  },
  
  // 商家账号
  {
    id: 'merchant_001',
    email: 'merchant@guigangwenlv.com',
    phone: '13800138002',
    password: 'Merchant123456',
    userType: 'merchant',
    username: '贵港文旅酒店',
    merchantInfo: {
      merchantId: 'M2024001',
      merchantName: '贵港文旅酒店',
      businessLicense: '91450800MA5NH8XY2L',
      address: '广西贵港市港北区中山路88号',
      contactPerson: '张经理',
      contactPhone: '13800138002',
      merchantType: 'hotel',
      verifyStatus: 'verified',
      rating: 4.8
    },
    permissions: [
      'merchant:basic',
      'merchant:order',
      'merchant:product',
      'merchant:promotion',
      'merchant:statistics'
    ],
    status: 'active',
    createTime: '2024-01-02 00:00:00'
  },
  
  // 普通用户账号
  {
    id: 'user_001',
    email: 'user@example.com',
    phone: '13800138003',
    password: 'User123456',
    userType: 'user',
    username: '文旅用户',
    userInfo: {
      nickname: '快乐游客',
      gender: '保密',
      birthday: '1990-01-01',
      avatar: '/avatars/default.png',
      level: 1,
      points: 100
    },
    permissions: [
      'user:basic',
      'order:create',
      'comment:create',
      'favorite:manage'
    ],
    status: 'active',
    createTime: '2024-01-03 00:00:00'
  }
];

// 权限配置
export const permissionConfig = {
  admin: {
    name: '系统管理员',
    description: '拥有系统最高权限',
    permissions: [
      {
        code: 'system:manage',
        name: '系统管理',
        operations: ['view', 'add', 'edit', 'delete']
      },
      {
        code: 'user:manage',
        name: '用户管理',
        operations: ['view', 'add', 'edit', 'delete']
      },
      {
        code: 'merchant:manage',
        name: '商家管理',
        operations: ['view', 'verify', 'disable', 'delete']
      },
      {
        code: 'content:manage',
        name: '内容管理',
        operations: ['view', 'add', 'edit', 'delete']
      },
      {
        code: 'order:manage',
        name: '订单管理',
        operations: ['view', 'process', 'refund']
      },
      {
        code: 'statistics:view',
        name: '统计数据',
        operations: ['view']
      }
    ]
  },
  
  merchant: {
    name: '商家',
    description: '提供服务的商家用户',
    permissions: [
      {
        code: 'merchant:basic',
        name: '基础信息管理',
        operations: ['view', 'edit']
      },
      {
        code: 'merchant:order',
        name: '订单管理',
        operations: ['view', 'process', 'refund']
      },
      {
        code: 'merchant:product',
        name: '产品管理',
        operations: ['view', 'add', 'edit', 'delete']
      },
      {
        code: 'merchant:promotion',
        name: '促销管理',
        operations: ['view', 'add', 'edit', 'delete']
      },
      {
        code: 'merchant:statistics',
        name: '统计数据',
        operations: ['view']
      }
    ]
  },
  
  user: {
    name: '普通用户',
    description: '平台注册用户',
    permissions: [
      {
        code: 'user:basic',
        name: '基础功能',
        operations: ['view', 'edit']
      },
      {
        code: 'order:create',
        name: '订单功能',
        operations: ['create', 'cancel', 'pay']
      },
      {
        code: 'comment:create',
        name: '评论功能',
        operations: ['create', 'delete']
      },
      {
        code: 'favorite:manage',
        name: '收藏功能',
        operations: ['add', 'delete']
      }
    ]
  }
};

// 登录验证函数
export const validateLogin = (email, phone, password, userType) => {
  const user = testUsers.find(u => 
    (u.email === email || u.phone === phone) && 
    u.password === password &&
    u.userType === userType
  );
  
  if (user) {
    // 返回用户信息（排除敏感信息）
    const { password, ...safeUserInfo } = user;
    return {
      success: true,
      data: {
        ...safeUserInfo,
        token: \`\${userType}_token_\${Date.now()}\` // 模拟生成token
      }
    };
  }
  
  return {
    success: false,
    message: '账号或密码错误'
  };
}; 